/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package control

import dao.CustodyDAO
import entity.Custody
/**
 *
 * @author Tato
 */
class ControlCustody {
    
    CustodyDAO dao = new CustodyDAO()
     
    def addCustody(Custody custody){
            
        key = dao.create(custody,DBConnection.establishConection())
        if(key > 0){       
               custody.id= key
               "Agregado"
        }
        else{
            "No agregado"
        }
           
                
    }
    
    def deleteCustody(Custody custody){
        
        custody = dao.remove(custody,DBConnection.establishConection())
        
        if(delete == true){
            "Borrado exitoso"
        }
        else{
            "Borrado falló"
        }     
    }
    
    def updateCustody(Custody custody){
        if(dao.update(custody,DBConnection.establishConection()) > 0){
               "Información actualizada"
            }
            
            else {
                "Información no actualizada"
            }
        
    }
    
     def findSample(Integer id){
         if(dao.find(id,DBConnection.establishConection())!= null  ){
               "Información actualizada"
            }
            
            else {
                "Información no actualizada"
            }
        
    }
	
}

